package com.cg.design.graphicdesignpattern.mediator;

import java.awt.*;

/**
 * 表示按钮的类，实现了Colleague接口，继承了java.awt.Button类
 *
 * @program: LeetCode->ColleagueButton
 * @description: 表示按钮的类，实现了Colleague接口，继承了java.awt.Button类
 * @author: cg
 * @create: 2022-03-28 10:31
 **/
public class ColleagueButton extends Button implements Colleague {

    /**
     * 中介者
     */
    private Mediator mediator;

    public ColleagueButton(String caption) {
        super(caption);
    }

    @Override
    public void setMediator(Mediator mediator) {
        // 保存Mediator
        this.mediator = mediator;
    }

    @Override
    public void setColleagueEnabled(boolean enabled) {
        // 根据中介者的指令下达启用/禁用
        setEnabled(enabled);
    }
}
